package com.base.mine.presenter;

import android.app.Activity;

import com.base.commonlib.base.presenter.BasePresenter;
import com.base.commonlib.http.RealNetWorkUtil;
import com.base.commonlib.http.utils.CallBackImpl;
import com.base.mine.view.SettingView;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.disposables.Disposable;

/**
 * Created by zw on 2019/10/29.
 */

public class SettingPresenter extends BasePresenter<SettingView>{
    public SettingPresenter(SettingView view, Activity activity) {
        super(view, activity);
    }

    public void loginOut(String userId){
        Map<String,Object> param = new HashMap<>();
        param.put("userId",userId);
        param.put("platform",1);
        Disposable enqueue = RealNetWorkUtil.postContent().method("api-auth/logout")
                .content(param)
                .build().enqueue(String.class, new CallBackImpl<String>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                       // mView.showError();
                       // mView.showMes(msg);
                        mView.returnLoginOut("退出成功");
                    }

                    @Override
                    public void onNext(String s) {
                        mView.returnLoginOut(s);
                    }
                });
        mCompositeDisposable.add(enqueue);

    }



    public void destroy(){
        Map<String,Object> param = new HashMap<>();
        Disposable enqueue = RealNetWorkUtil.postContent().method("api-auth/clean")
                .content(param)
                .build().enqueue(String.class, new CallBackImpl<String>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.showError();
                        mView.showMes(msg);
                    }

                    @Override
                    public void onNext(String s) {
                        mView.returnDestroy(s);
                    }
                });
        mCompositeDisposable.add(enqueue);

    }
}
